﻿using System;
using System.Data.SqlClient;
using Devv.Core.UniDataTier;

namespace Yglu.BusinessLayer.Entities
{
	public class Promotion : BaseEntity
	{
		#region Properties

		public Int32 StoreId { get; set; }
		public String Title { get; set; }
		public Double Discount { get; set; }
		public Int32 Products { get; set; }
		public Int32 Combos { get; set; }
		public Boolean IsPercent { get; set; }
		public Boolean Automatic { get; set; }
		public Boolean AllStores { get; set; }

		#endregion

		#region Extra properties

		public String DisplayTitle
		{
			get
			{
				return Title;
			}
		}

		#endregion

		#region Constructor

		public Promotion()
		{
		}

		public Promotion(Int32 id)
		{
			Construct(DataAccess.Promotion_Get(id));
		}

		public Promotion(SqlDataReader reader)
		{
			Construct(reader);
		}

		#endregion

		#region Methods

		public override void Load(SqlDataReader reader)
		{
			Id = DataHandler.GetInt32(reader, "PromotionId");
			Title = DataHandler.GetString(reader, "PromotionTitle");
			Discount = DataHandler.GetDouble(reader, "PromotionDiscount");
			Products = DataHandler.GetInt32(reader, "PromotionProducts", 0);
			Combos = DataHandler.GetInt32(reader, "PromotionCombos", 0);
			IsPercent = DataHandler.GetBoolean(reader, "PromotionIsPercent");
			Automatic = DataHandler.GetBoolean(reader, "PromotionAutomatic");
			AllStores = DataHandler.GetBoolean(reader, "PromotionAllStores");
			Active = DataHandler.GetBoolean(reader, "PromotionActive");
		}

		#endregion
	}
}